import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import GridSearchCV, train_test_split
from sklearn.linear_model import Ridge
from sklearn.datasets import load_boston

x, y = load_boston(return_X_y=True)

x_train, x_test, y_train, y_test = train_test_split(x, y, train_size=0.7)

estimator = Ridge()
params = dict(alpha=[0, 0.1, 0.2, 0.5, 0.8, 1, 5, 10])
grid = GridSearchCV(estimator, params, cv=5, iid=True)
grid.fit(x_train, y_train)
print(grid.best_score_)
print(grid.best_params_)
